package com.sticktogether.services;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class MyBroadcastreceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
        SharedPreferences settings;
        settings = context.getSharedPreferences("Config1", 0);
    	SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
    	// If the user is logged in (id and ps stored on device) and tracking is enabled, start the tracking service.
    	if(sharedPref.getBoolean("tracking_enable", true) && !settings.getString("id", "").equals("") && !settings.getString("sid", "").equals("")) {
			Intent Serviceintent = new Intent(context, GpsService.class);
	    	context.startService(Serviceintent);
    	}
	}

}
